// import Vue from 'vue'
// import Vuex from 'vuex'
 
// Vue.use(Vuex)
import { createStore } from 'vuex'

const store = createStore({
  state: {
    name: "",
    data:{}
  },
  getters: {
    getName: state => state.name,
    getschool:state=>state.school
  },
  mutations: {
    update(state, newName,newgender,newwork,newaddress,newxingzi,newschool,newage) {
      state.name = newName;
      state.address=newaddress;
      state.age=newage;
      state.xingzi=newxingzi;
      state.school=newschool;
      state.gender=newgender;
      // state.xueli=newxueli
      state.work=newwork;
    },
    updateName(state, newName) {
      state.name = newName;
      localStorage.setItem("username",newName);
    },
    updatadata(state,newdata){
      state.data=newdata;
      localStorage.setItem("Date",JSON.stringify(newdata));
    }
  },
  actions: {},
  modules: {}
})
 
// const store= new Vuex.Store({
//   //数据，相当于data
//   state: {
//     name:""
//   },
//   getters: {
//     getName: state => state.name
    
//   },
//   //里面定义方法，操作state方发
//   mutations: {
//     updateName(state, newName) {
//         state.name = newName;
//       }
//   },
//   // 操作异步操作mutation
//   actions: {
    
//   },
//   modules: {
    
//   },
// })
export default store